package cn.edu.tsinghua.smxq.mobilecity.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import cn.edu.tsinghua.smxq.mobilecity.po.UserLog;
import cn.edu.tsinghua.smxq.mobilecity.utils.DBUtils;

public class UserLogDAO {
	
	public boolean create(UserLog userLog) throws SQLException {
		boolean success = false;
		Connection conn = DBUtils.Connect();
		PreparedStatement pstmt = conn
				.prepareStatement("INSERT INTO mobilecity.userlog(userid,servicetype,url,time) values(?,?,?,?)");
		pstmt.setInt(1, userLog.getUserId());
		pstmt.setInt(2, userLog.getServiceType());
		pstmt.setString(3, userLog.getUrl());
		pstmt.setTimestamp(4, userLog.getTime());
	
		if (pstmt.executeUpdate() == 1) {
			success = true;
		}
		pstmt.close();
		conn.close();
		return success;
	}

}
